*Treatment data: see 1.Code_Paper
*Cointerventions: see 1.Code_Paper
*Outcome samples: see 1.Code_Paper

*Appendix B Table
use othercontrols.dta
merge 1:1 bmunicipality byear using mws.dta
foreach var in urban north south lntraffic lnrailways lnmunincome shareagriculture shareindustry countygdp females under15 lncdr sharedisabled lnschools lnbirths lnpharmacies lnstillbirths ///
lnpop lnimr lnmmr lnpneumonia sulpha {
	tabstat  `var' wrongregister, bonferroni	
}

*Appendix D Table
foreach i in hospitalshare earlymortality latemortality neonatalmortality lnlabourincome disabled unemployed totalhospitalstay yearsofschooling secondaryschool specificfield service nonmanual {
	use `i'.dta, replace
	merge m:1 bmunicipality byear using mws.dta
	keep if _merge==3
	keep if wrongregister==0
	estpost sum mainoutcome postXMW postXTypeIMW postXTypeIIMW postXPrivateMW, stats(mean sd N)
	esttab, cells("mean sd count")
	}

*Appendix E Table
foreach i in hospitalshare earlymortality latemortality neonatalmortality premature fulltermstillbirths stillbirths sickmothers {
	use `i'.dta, replace
	merge 1:1 bmunicipality byear using mws.dta
	xtset bmunicipality
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban if wrongregister==0, fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban if wrongregister==0 & (treated==1 | nevertreated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban if wrongregister==0 & (treated==1 | alwaystreated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban if wrongregister==0 & (treated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
}
*Appendix E Figure
foreach i in premature fulltermstillbirths stillbirths sickmothers {
	use `i'.dta, replace
	merge 1:1 bmunicipality byear using mws.dta
	xtset bmunicipality
	xtreg mainoutcome pre6XMW pre5XMW pre4XMW pre3XMW pre2XMW post1XMW post2XMW post3XMW post4XMW post5XMW post4XMW i.byear i.byear#i.regionXurban if wrongregister==0, fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label ci level(95) e(all) dec(3)
}
*Copy the estimated event-study coefficients (called `i'point) and confidence intervals (called `i'lower `i'upper) to a new Stata dataset
*Note that event years >=6 and <=6 are esimated but not plotted:
label define eventyear 1 "-5th year" 2 "-4th year" 3 "-3rd year" 4 "-2nd year" 5 "-1st year" 6 "1st year" 7 "2nd year" ///
 8 "3rd year" 9 "4th year" 10 "5th year" 
label values eventyear eventyear

tsset eventyear
foreach i in premature fulltermstillbirths stillbirths sickmothers {
	tsline `i'point `i'lower `i'upper
	graph export `i'eventstudy.eps, as(eps) replace
}

*Appendix F Table
foreach i in lnlabourincome disabled unemployed totalhospitalstay yearsofschooling secondaryschool specificfield service nonmanual {
	use `i'.dta, replace
	merge 1:1 bmunicipality byear using mws.dta
	xtset bmunicipality
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban i.sex if wrongregister==0, fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban i.sex if wrongregister==0 & (treated==1 | nevertreated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban i.sex if wrongregister==0 & (treated==1 | alwaystreated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban i.sex if wrongregister==0 & (treated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
}

*Appendix G Table G.2
foreach i in infectious cardiovascular diabetes cancer degenerative mental {
	use `i'.dta, replace
	merge 1:1 bmunicipality byear using mws.dta
	xtset bmunicipality
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban i.sex if wrongregister==0, fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban i.sex if wrongregister==0 & (treated==1 | nevertreated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban i.sex if wrongregister==0 & (treated==1 | alwaystreated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban i.sex if wrongregister==0 & (treated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
}

*Appendix G Table G.3
foreach i in postmortality childmortality adultmortality1536 adultmortality3764 {
	use `i'.dta, replace
	merge 1:1 bmunicipality byear using mws.dta
	xtset bmunicipality
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban if wrongregister==0, fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban if wrongregister==0 & (treated==1 | nevertreated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban if wrongregister==0 & (treated==1 | alwaystreated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban if wrongregister==0 & (treated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
}
*Appendix G Table G.4
foreach i in infectiousmort cardiovascularmort diabetesmort cancermort degenerativemort mentalmort othermort {
	use `i'.dta, replace
	merge 1:1 bmunicipality byear using mws.dta
	xtset bmunicipality
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban i.sex if wrongregister==0, fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban i.sex if wrongregister==0 & (treated==1 | nevertreated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban i.sex if wrongregister==0 & (treated==1 | alwaystreated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban i.sex if wrongregister==0 & (treated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
}
*Appendix G Figure G.1
foreach i in postmortality childmortality adultmortality1536 adultmortality3764 {
	use `i'.dta, replace
	merge 1:1 bmunicipality byear using mws.dta
	xtset bmunicipality
	xtreg mainoutcome pre6XMW pre5XMW pre4XMW pre3XMW pre2XMW post1XMW post2XMW post3XMW post4XMW post5XMW post4XMW i.byear i.byear#i.regionXurban if wrongregister==0, fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label ci level(95) e(all) dec(3)
}
*Copy the estimated event-study coefficients (called `i'point) and confidence intervals (called `i'lower `i'upper) to a new Stata dataset
*Note that event years >=6 and <=6 are esimated but not plotted:
label define eventyear 1 "-5th year" 2 "-4th year" 3 "-3rd year" 4 "-2nd year" 5 "-1st year" 6 "1st year" 7 "2nd year" ///
 8 "3rd year" 9 "4th year" 10 "5th year" 
label values eventyear eventyear

tsset eventyear
foreach i in postmortality childmortality adultmortality1536 adultmortality3764 {
	tsline `i'point `i'lower `i'upper
	graph export `i'eventstudy.eps, as(eps) replace
}
*Appendix G Figure G.2
foreach i in infectiousmort cardiovascularmort diabetesmort cancermort degenerativemort mentalmort othermort {
	use `i'.dta, replace
	merge 1:1 bmunicipality byear using mws.dta
	xtset bmunicipality
	xtreg mainoutcome pre6XMW pre5XMW pre4XMW pre3XMW pre2XMW post1XMW post2XMW post3XMW post4XMW post5XMW post4XMW i.byear i.byear#i.regionXurban i.sex if wrongregister==0, fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label ci level(95) e(all) dec(3)
}
*Copy the estimated event-study coefficients (called `i'point) and confidence intervals (called `i'lower `i'upper) to a new Stata dataset
*Note that event years >=6 and <=6 are esimated but not plotted:
label define eventyear 1 "-5th year" 2 "-4th year" 3 "-3rd year" 4 "-2nd year" 5 "-1st year" 6 "1st year" 7 "2nd year" ///
 8 "3rd year" 9 "4th year" 10 "5th year" 
label values eventyear eventyear

tsset eventyear
foreach i in infectiousmort cardiovascularmort diabetesmort cancermort degenerativemort mentalmort othermort {
	tsline `i'point `i'lower `i'upper
	graph export `i'eventstudy.eps, as(eps) replace
}
*Appendix G Figure G.3
foreach i in infectious cardiovascular diabetes cancer degenerative mental {
	use `i'.dta, replace
	merge 1:1 bmunicipality byear using mws.dta
	xtset bmunicipality
	xtreg mainoutcome pre6XMW pre5XMW pre4XMW pre3XMW pre2XMW post1XMW post2XMW post3XMW post4XMW post5XMW post4XMW i.byear i.byear#i.regionXurban i.sex if wrongregister==0, fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label ci level(95) e(all) dec(3)
}
*Copy the estimated event-study coefficients (called `i'point) and confidence intervals (called `i'lower `i'upper) to a new Stata dataset
*Note that event years >=6 and <=6 are esimated but not plotted:
label define eventyear 1 "-5th year" 2 "-4th year" 3 "-3rd year" 4 "-2nd year" 5 "-1st year" 6 "1st year" 7 "2nd year" ///
 8 "3rd year" 9 "4th year" 10 "5th year" 
label values eventyear eventyear

tsset eventyear
foreach i in infectious cardiovascular diabetes cancer degenerative mental {
	tsline `i'point `i'lower `i'upper
	graph export `i'eventstudy.eps, as(eps) replace
}

*Appendix H
*in sex: 1=men, 2=women
foreach val in 1 2 {
foreach i in socialsciences naturalsciences medicine otherfields agriculture industry building transport publicservices private government publicadmin teaching {
	use `i'.dta, replace
	merge 1:1 bmunicipality byear using mws.dta
	xtset bmunicipality
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban i.sex if wrongregister==0 & sex==`val', fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban i.sex if wrongregister==0 & (treated==1 | nevertreated==1) & sex==`val', fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban i.sex if wrongregister==0 & (treated==1 | alwaystreated==1) & sex==`val', fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban i.sex if wrongregister==0 & (treated==1) & sex==`val', fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
}
}

*Appendix I Table
*(i)
foreach i in hospitalshare earlymortality latemortality neonatalmortality premature fulltermstillbirths stillbirths sickmothers {
	use `i'.dta, replace
	merge 1:1 bmunicipality byear using mws.dta
	xtset bmunicipality
	xtreg mainoutcome postXMW i.byear c.byear#i.regionXurban if wrongregister==0, fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) keep(postXMW) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear c.byear#i.regionXurban if wrongregister==0 & (treated==1 | nevertreated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) keep(postXMW) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear c.byear#i.regionXurban if wrongregister==0 & (treated==1 | alwaystreated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) keep(postXMW) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear c.byear#i.regionXurban if wrongregister==0 & (treated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) keep(postXMW) word label se e(all) dec(3)
}
foreach i in lnlabourincome disabled unemployed totalhospitalstay yearsofschooling secondaryschool specificfield service nonmanual {
	use `i'.dta, replace
	merge 1:1 bmunicipality byear using mws.dta
	xtset bmunicipality
	xtreg mainoutcome postXMW i.byear c.byear#i.regionXurban i.sex if wrongregister==0, fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) keep(postXMW) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear c.byear#i.regionXurban i.sex if wrongregister==0 & (treated==1 | nevertreated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) keep(postXMW) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear c.byear#i.regionXurban i.sex if wrongregister==0 & (treated==1 | alwaystreated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) keep(postXMW) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear c.byear#i.regionXurban i.sex if wrongregister==0 & (treated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) keep(postXMW) word label se e(all) dec(3)
}
*(ii)
foreach i in hospitalshare earlymortality latemortality neonatalmortality premature fulltermstillbirths stillbirths sickmothers {
	use `i'.dta, replace
	merge 1:1 bmunicipality byear using mws.dta
	xtset bmunicipality
	xtreg mainoutcome postXMW i.byear c.byear#c.lnmunincome c.byear#c.shareagriculture c.byear#c.shareindustry  c.byear#c.countygdp c.byear#c.lndoctors c.byear#c.lnmidwives c.byear#c.lnnurses  c.byear#c.lnhospitals  c.byear#c.lnexpenditures c.byear#c.lnpharmacies c.byear#c.females c.byear#c.under15 c.byear#c.lncdr c.byear#c.sharedisabled c.byear#c.lnschools c.byear#c.lnbirths c.byear#c.lnimr c.byear#c.lnmmr c.byear#c.lnpneumonia c.byear#c.lntraffic c.byear#c.lnrailways  c.byear#c.lnstillbirths c.byear#c.sulpha if wrongregister==0, fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) keep(postXMW) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear c.byear#c.lnmunincome c.byear#c.shareagriculture c.byear#c.shareindustry  c.byear#c.countygdp c.byear#c.lndoctors c.byear#c.lnmidwives c.byear#c.lnnurses  c.byear#c.lnhospitals  c.byear#c.lnexpenditures c.byear#c.lnpharmacies c.byear#c.females c.byear#c.under15 c.byear#c.lncdr c.byear#c.sharedisabled c.byear#c.lnschools c.byear#c.lnbirths c.byear#c.lnimr c.byear#c.lnmmr c.byear#c.lnpneumonia c.byear#c.lntraffic c.byear#c.lnrailways  c.byear#c.lnstillbirths c.byear#c.sulpha if wrongregister==0 & (treated==1 | nevertreated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) keep(postXMW) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear c.byear#c.lnmunincome c.byear#c.shareagriculture c.byear#c.shareindustry  c.byear#c.countygdp c.byear#c.lndoctors c.byear#c.lnmidwives c.byear#c.lnnurses  c.byear#c.lnhospitals  c.byear#c.lnexpenditures c.byear#c.lnpharmacies c.byear#c.females c.byear#c.under15 c.byear#c.lncdr c.byear#c.sharedisabled c.byear#c.lnschools c.byear#c.lnbirths c.byear#c.lnimr c.byear#c.lnmmr c.byear#c.lnpneumonia c.byear#c.lntraffic c.byear#c.lnrailways  c.byear#c.lnstillbirths c.byear#c.sulpha if wrongregister==0 & (treated==1 | alwaystreated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) keep(postXMW) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear c.byear#c.lnmunincome c.byear#c.shareagriculture c.byear#c.shareindustry  c.byear#c.countygdp c.byear#c.lndoctors c.byear#c.lnmidwives c.byear#c.lnnurses  c.byear#c.lnhospitals  c.byear#c.lnexpenditures c.byear#c.lnpharmacies c.byear#c.females c.byear#c.under15 c.byear#c.lncdr c.byear#c.sharedisabled c.byear#c.lnschools c.byear#c.lnbirths c.byear#c.lnimr c.byear#c.lnmmr c.byear#c.lnpneumonia c.byear#c.lntraffic c.byear#c.lnrailways  c.byear#c.lnstillbirths c.byear#c.sulpha if wrongregister==0 & (treated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) keep(postXMW) word label se e(all) dec(3)
}
foreach i in lnlabourincome disabled unemployed totalhospitalstay yearsofschooling secondaryschool specificfield service nonmanual {
	use `i'.dta, replace
	merge 1:1 bmunicipality byear using mws.dta
	xtset bmunicipality
	xtreg mainoutcome postXMW i.byear c.byear#c.lnmunincome c.byear#c.shareagriculture c.byear#c.shareindustry  c.byear#c.countygdp c.byear#c.lndoctors c.byear#c.lnmidwives c.byear#c.lnnurses  c.byear#c.lnhospitals  c.byear#c.lnexpenditures c.byear#c.lnpharmacies c.byear#c.females c.byear#c.under15 c.byear#c.lncdr c.byear#c.sharedisabled c.byear#c.lnschools c.byear#c.lnbirths c.byear#c.lnimr c.byear#c.lnmmr c.byear#c.lnpneumonia c.byear#c.lntraffic c.byear#c.lnrailways  c.byear#c.lnstillbirths c.byear#c.sulpha i.sex if wrongregister==0, fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) keep(postXMW) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear c.byear#c.lnmunincome c.byear#c.shareagriculture c.byear#c.shareindustry  c.byear#c.countygdp c.byear#c.lndoctors c.byear#c.lnmidwives c.byear#c.lnnurses  c.byear#c.lnhospitals  c.byear#c.lnexpenditures c.byear#c.lnpharmacies c.byear#c.females c.byear#c.under15 c.byear#c.lncdr c.byear#c.sharedisabled c.byear#c.lnschools c.byear#c.lnbirths c.byear#c.lnimr c.byear#c.lnmmr c.byear#c.lnpneumonia c.byear#c.lntraffic c.byear#c.lnrailways  c.byear#c.lnstillbirths c.byear#c.sulpha i.sex if wrongregister==0 & (treated==1 | nevertreated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) keep(postXMW) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear c.byear#c.lnmunincome c.byear#c.shareagriculture c.byear#c.shareindustry  c.byear#c.countygdp c.byear#c.lndoctors c.byear#c.lnmidwives c.byear#c.lnnurses  c.byear#c.lnhospitals  c.byear#c.lnexpenditures c.byear#c.lnpharmacies c.byear#c.females c.byear#c.under15 c.byear#c.lncdr c.byear#c.sharedisabled c.byear#c.lnschools c.byear#c.lnbirths c.byear#c.lnimr c.byear#c.lnmmr c.byear#c.lnpneumonia c.byear#c.lntraffic c.byear#c.lnrailways  c.byear#c.lnstillbirths c.byear#c.sulpha i.sex if wrongregister==0 & (treated==1 | alwaystreated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) keep(postXMW) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear c.byear#c.lnmunincome c.byear#c.shareagriculture c.byear#c.shareindustry  c.byear#c.countygdp c.byear#c.lndoctors c.byear#c.lnmidwives c.byear#c.lnnurses  c.byear#c.lnhospitals  c.byear#c.lnexpenditures c.byear#c.lnpharmacies c.byear#c.females c.byear#c.under15 c.byear#c.lncdr c.byear#c.sharedisabled c.byear#c.lnschools c.byear#c.lnbirths c.byear#c.lnimr c.byear#c.lnmmr c.byear#c.lnpneumonia c.byear#c.lntraffic c.byear#c.lnrailways  c.byear#c.lnstillbirths c.byear#c.sulpha i.sex if wrongregister==0 & (treated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) keep(postXMW) word label se e(all) dec(3)
}
*(iii)
foreach i in hospitalshare earlymortality latemortality neonatalmortality premature fulltermstillbirths stillbirths sickmothers {
	use `i'.dta, replace
	merge 1:1 bmunicipality byear using mws.dta
	xtset bmunicipality
	xtreg mainoutcome postXMW i.byear c.byear#i.bmunicipality if wrongregister==0, fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) keep(postXMW) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear c.byear#i.bmunicipality if wrongregister==0 & (treated==1 | nevertreated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) keep(postXMW) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear c.byear#i.bmunicipality if wrongregister==0 & (treated==1 | alwaystreated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) keep(postXMW) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear c.byear#i.bmunicipality if wrongregister==0 & (treated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) keep(postXMW) word label se e(all) dec(3)
}
foreach i in lnlabourincome disabled unemployed totalhospitalstay yearsofschooling secondaryschool specificfield service nonmanual {
	use `i'.dta, replace
	merge 1:1 bmunicipality byear using mws.dta
	xtset bmunicipality
	xtreg mainoutcome postXMW i.byear c.byear#i.bmunicipality i.sex if wrongregister==0, fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) keep(postXMW) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear c.byear#i.bmunicipality i.sex if wrongregister==0 & (treated==1 | nevertreated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) keep(postXMW) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear c.byear#i.bmunicipality i.sex if wrongregister==0 & (treated==1 | alwaystreated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) keep(postXMW) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear c.byear#i.bmunicipality i.sex if wrongregister==0 & (treated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) keep(postXMW) word label se e(all) dec(3)
}

*Appendix J Table J.1
foreach i in earlymortality latemortality neonatalmortality postmortality childmortality  {
	use `i'.dta, replace
	merge m:1 bmunicipality byear using mws.dta
	drop _merge
	merge m:1 bmunicipality byear using sulpha.dta
	xtset bmunicipality
	xtreg mainoutcome postXMW cointervention i.byear if wrongregister==0, fe vce(cluster bmunicipality)
	outreg2 using sulpha, cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW cointervention postXMW#cointervention i.byear if wrongregister==0, fe vce(cluster bmunicipality)
	outreg2 using sulpha, cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW cointervention i.byear if wrongregister==0 & (treated==1 | nevertreated==1), fe vce(cluster bmunicipality)
	outreg2 using sulpha, cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW cointervention postXMW#cointervention i.byear if wrongregister==0 & (treated==1 | nevertreated==1), fe vce(cluster bmunicipality)
	outreg2 using sulpha, cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW cointervention i.byear if wrongregister==0 & (treated==1 | alwaystreated==1), fe vce(cluster bmunicipality)
	outreg2 using sulpha, cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW cointervention postXMW#cointervention i.byear if wrongregister==0 & (treated==1 | alwaystreated==1), fe vce(cluster bmunicipality)
	outreg2 using sulpha, cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW cointervention i.byear if wrongregister==0 & (treated==1), fe vce(cluster bmunicipality)
	outreg2 using sulpha, cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW cointervention postXMW#cointervention i.byear if wrongregister==0 & (treated==1), fe vce(cluster bmunicipality)
	outreg2 using sulpha, cttop(coefficient) word label se e(all) dec(3)
}

foreach i in earlymortality latemortality neonatalmortality postmortality childmortality  {
	use `i'.dta, replace
	merge m:1 bmunicipality byear using mws.dta
	drop _merge
	merge m:1 bmunicipality byear using wellchild.dta
	xtset bmunicipality
	xtreg mainoutcome postXMW cointervention i.byear i.byear#i.regionXurban if wrongregister==0, fe vce(cluster bmunicipality)
	outreg2 using wellchild, cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW cointervention postXMW#cointervention i.byear i.byear#i.regionXurban if wrongregister==0, fe vce(cluster bmunicipality)
	outreg2 using wellchild, cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW cointervention i.byear i.byear#i.regionXurban if wrongregister==0 & (treated==1 | nevertreated==1), fe vce(cluster bmunicipality)
	outreg2 using wellchild, cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW cointervention postXMW#cointervention i.byear i.byear#i.regionXurban if wrongregister==0 & (treated==1 | nevertreated==1), fe vce(cluster bmunicipality)
	outreg2 using wellchild, cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW cointervention i.byear i.byear#i.regionXurban if wrongregister==0 & (treated==1 | alwaystreated==1), fe vce(cluster bmunicipality)
	outreg2 using wellchild, cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW cointervention postXMW#cointervention i.byear i.byear#i.regionXurban if wrongregister==0 & (treated==1 | alwaystreated==1), fe vce(cluster bmunicipality)
	outreg2 using wellchild, cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW cointervention i.byear i.byear#i.regionXurban if wrongregister==0 & (treated==1), fe vce(cluster bmunicipality)
	outreg2 using wellchild, cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW cointervention postXMW#cointervention i.byear i.byear#i.regionXurban if wrongregister==0 & (treated==1), fe vce(cluster bmunicipality)
	outreg2 using wellchild, cttop(coefficient) word label se e(all) dec(3)
}
*Figure J.1
*Sulpha
foreach i in neonatalmortality postmortality childmortality {
	use `i'.dta, replace
	merge m:1 bmunicipality byear using mws.dta
	drop _merge
	merge m:1 bmunicipality byear using sulpha.dta
	xtset bmunicipality
	xtreg mainoutcome pre6Xcointervention pre5Xcointervention pre4Xcointervention pre3Xcointervention pre2Xcointervention post1Xcointervention post2Xcointervention post3Xcointervention post4Xcointervention post5Xcointervention post4Xcointervention i.byear i.sex if wrongregister==0, fe vce(cluster bmunicipality)
	outreg2 using sulpha, cttop(coefficient) word label ci level(95) e(all) dec(3)
}
*Copy the estimated event-study coefficients (called `i'point) and confidence intervals (called `i'lower `i'upper) to a new Stata dataset
*Note that event years >=6 and <=6 are esimated but not plotted:
label define eventyear 1 "-5th year" 2 "-4th year" 3 "-3rd year" 4 "-2nd year" 5 "-1st year" 6 "1st year" 7 "2nd year" ///
 8 "3rd year" 9 "4th year" 10 "5th year" 
label values eventyear eventyear

tsset eventyear
foreach i in neonatalmortality postmortality childmortality {
	tsline `i'point `i'lower `i'upper
	graph export `i'eventstudysulpha.eps, as(eps) replace
}
*Well-child
foreach i in neonatalmortality postmortality childmortality {
	use `i'.dta, replace
	merge m:1 bmunicipality byear using mws.dta
	drop _merge
	merge m:1 bmunicipality byear using wellchild.dta
	xtset bmunicipality
	xtreg mainoutcome pre6Xcointervention pre5Xcointervention pre4Xcointervention pre3Xcointervention pre2Xcointervention post1Xcointervention post2Xcointervention post3Xcointervention post4Xcointervention post5Xcointervention post4Xcointervention i.byear i.byear#i.regionXurban i.sex if wrongregister==0, fe vce(cluster bmunicipality)
	outreg2 using wellchild, cttop(coefficient) word label ci level(95) e(all) dec(3)
}
*Copy the estimated event-study coefficients (called `i'point) and confidence intervals (called `i'lower `i'upper) to a new Stata dataset
*Note that event years >=6 and <=6 are esimated but not plotted:
label define eventyear 1 "-5th year" 2 "-4th year" 3 "-3rd year" 4 "-2nd year" 5 "-1st year" 6 "1st year" 7 "2nd year" ///
 8 "3rd year" 9 "4th year" 10 "5th year" 
label values eventyear eventyear

tsset eventyear
foreach i in neonatalmortality postmortality childmortality {
	tsline `i'point `i'lower `i'upper
	graph export `i'eventstudywellchild.eps, as(eps) replace
}
*Table J.2
*Sulpha
foreach i in  disabled unemployed {
	use `i'.dta, replace
	merge m:1 bmunicipality byear using mws.dta
	drop _merge
	merge m:1 bmunicipality byear using sulpha.dta
	xtset bmunicipality
	xtreg mainoutcome postXMW cointervention i.byear i.sex if wrongregister==0, fe vce(cluster bmunicipality)
	outreg2 using sulpha, cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW cointervention postXMW#cointervention i.byear i.sex if wrongregister==0, fe vce(cluster bmunicipality)
	outreg2 using sulpha, cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW cointervention i.byear i.sex if wrongregister==0 & (treated==1 | nevertreated==1), fe vce(cluster bmunicipality)
	outreg2 using sulpha, cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW cointervention postXMW#cointervention i.byear i.sex if wrongregister==0 & (treated==1 | nevertreated==1), fe vce(cluster bmunicipality)
	outreg2 using sulpha, cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW cointervention i.byear i.sex if wrongregister==0 & (treated==1 | alwaystreated==1), fe vce(cluster bmunicipality)
	outreg2 using sulpha, cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW cointervention postXMW#cointervention i.byear i.sex if wrongregister==0 & (treated==1 | alwaystreated==1), fe vce(cluster bmunicipality)
	outreg2 using sulpha, cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW cointervention i.byear i.sex if wrongregister==0 & (treated==1), fe vce(cluster bmunicipality)
	outreg2 using sulpha, cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW cointervention postXMW#cointervention i.byear i.sex if wrongregister==0 & (treated==1), fe vce(cluster bmunicipality)
	outreg2 using sulpha, cttop(coefficient) word label se e(all) dec(3)
}
*Well-child program
foreach i in  disabled unemployed {
	use `i'.dta, replace
	merge m:1 bmunicipality byear using mws.dta
	drop _merge
	merge m:1 bmunicipality byear using wellchild.dta
	xtset bmunicipality
	xtreg mainoutcome postXMW cointervention i.byear i.byear#i.regionXurban i.sex if wrongregister==0, fe vce(cluster bmunicipality)
	outreg2 using wellchild, cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW cointervention postXMW#cointervention i.byear i.byear#i.regionXurban i.sex if wrongregister==0, fe vce(cluster bmunicipality)
	outreg2 using wellchild, cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW cointervention i.byear i.byear#i.regionXurban i.sex if wrongregister==0 & (treated==1 | nevertreated==1), fe vce(cluster bmunicipality)
	outreg2 using wellchild, cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW cointervention postXMW#cointervention i.byear i.byear#i.regionXurban i.sex if wrongregister==0 & (treated==1 | nevertreated==1), fe vce(cluster bmunicipality)
	outreg2 using wellchild, cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW cointervention i.byear i.byear#i.regionXurban i.sex if wrongregister==0 & (treated==1 | alwaystreated==1), fe vce(cluster bmunicipality)
	outreg2 using wellchild, cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW cointervention postXMW#cointervention i.byear i.byear#i.regionXurban i.sex if wrongregister==0 & (treated==1 | alwaystreated==1), fe vce(cluster bmunicipality)
	outreg2 using wellchild, cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW cointervention i.byear i.byear#i.regionXurban i.sex if wrongregister==0 & (treated==1), fe vce(cluster bmunicipality)
	outreg2 using wellchild, cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW cointervention postXMW#cointervention i.byear i.byear#i.regionXurban i.sex if wrongregister==0 & (treated==1), fe vce(cluster bmunicipality)
	outreg2 using wellchild, cttop(coefficient) word label se e(all) dec(3)
}
*Table J.3
prontosil.dta, replace
wwii.dta, replace
schoolingreform.dta, replace
*Sulpha
foreach val in prontosil wwii schoolingreform {
foreach i in lnlabourincome disabled unemployed {
	use `i'.dta, replace
	merge m:1 bmunicipality byear using mws.dta
	drop _merge
	merge m:1 bmunicipality byear using `val'.dta
	xtset bmunicipality
	xtreg mainoutcome postXMW cointervention i.byear i.byear#i.regionXurban i.sex if wrongregister==0, fe vce(cluster bmunicipality)
	outreg2 using `val', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW cointervention postXMW#cointervention i.byear i.byear#i.regionXurban i.sex if wrongregister==0, fe vce(cluster bmunicipality)
	outreg2 using `val', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW cointervention i.byear i.byear#i.regionXurban i.sex if wrongregister==0 & (treated==1 | nevertreated==1), fe vce(cluster bmunicipality)
	outreg2 using `val', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW cointervention postXMW#cointervention i.byear i.byear#i.regionXurban i.sex if wrongregister==0 & (treated==1 | nevertreated==1), fe vce(cluster bmunicipality)
	outreg2 using `val', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW cointervention i.byear i.byear#i.regionXurban i.sex if wrongregister==0 & (treated==1 | alwaystreated==1), fe vce(cluster bmunicipality)
	outreg2 using `val', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW cointervention postXMW#cointervention i.byear i.byear#i.regionXurban i.sex if wrongregister==0 & (treated==1 | alwaystreated==1), fe vce(cluster bmunicipality)
	outreg2 using `val', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW cointervention i.byear i.byear#i.regionXurban i.sex if wrongregister==0 & (treated==1), fe vce(cluster bmunicipality)
	outreg2 using `val', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW cointervention postXMW#cointervention i.byear i.byear#i.regionXurban i.sex if wrongregister==0 & (treated==1), fe vce(cluster bmunicipality)
	outreg2 using `val', cttop(coefficient) word label se e(all) dec(3)
}
}
*Table J.4
foreach i in lndoctors lnmidwives lnnurses lnhospitals lnexpenditures {
	use `i'.dta, replace
	merge 1:1 bmunicipality byear using mws.dta
	xtset bmunicipality
	xtreg mainoutcome postXMW i.byear c.byear#i.regionXurban if wrongregister==0, fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) keep(postXMW) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear c.byear#i.regionXurban if wrongregister==0 & (treated==1 | nevertreated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) keep(postXMW) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear c.byear#i.regionXurban if wrongregister==0 & (treated==1 | alwaystreated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) keep(postXMW) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear c.byear#i.regionXurban if wrongregister==0 & (treated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) keep(postXMW) word label se e(all) dec(3)
}
*Figure J.2
foreach i in lndoctors lnmidwives lnnurses lnhospitals lnexpenditures {
	use `i'.dta, replace
	merge m:1 bmunicipality byear using mws.dta
	xtset bmunicipality
	xtreg mainoutcome pre6XMW pre5XMW pre4XMW pre3XMW pre2XMW post1XMW post2XMW post3XMW post4XMW post5XMW post4XMW i.byear c.byear#i.regionXurban if wrongregister==0, fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label ci level(95) e(all) dec(3)
}
*Copy the estimated event-study coefficients (called `i'point) and confidence intervals (called `i'lower `i'upper) to a new Stata dataset
*Note that event years >=6 and <=6 are esimated but not plotted:
label define eventyear 1 "-5th year" 2 "-4th year" 3 "-3rd year" 4 "-2nd year" 5 "-1st year" 6 "1st year" 7 "2nd year" ///
 8 "3rd year" 9 "4th year" 10 "5th year" 
label values eventyear eventyear

tsset eventyear
foreach i in lndoctors lnmidwives lnnurses lnhospitals lnexpenditures {
	tsline `i'point `i'lower `i'upper
	graph export `i'eventstudy.eps, as(eps) replace
}
*Table J.5
foreach i in hospitalshare earlymortality latemortality neonatalmortality postmortality {
	use `i'.dta, replace
	merge 1:1 bmunicipality byear using mws.dta
	gen postXMWXpre1938=(postXMW==1 & byear<1938)
	gen postXMWXpost1938=(postXMW==1 & byear>=1938)
	xtset bmunicipality
	xtreg mainoutcome postXMWXpre1938 postXMWXpost1938 i.byear i.byear#i.regionXurban if wrongregister==0, fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMWXpre1938 postXMWXpost1938 i.byear i.byear#i.regionXurban if wrongregister==0 & (treated==1 | nevertreated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMWXpre1938 postXMWXpost1938 i.byear i.byear#i.regionXurban if wrongregister==0 & (treated==1 | alwaystreated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMWXpre1938 postXMWXpost1938 i.byear i.byear#i.regionXurban if wrongregister==0 & (treated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
}
foreach i in lnlabourincome disabled unemployed totalhospitalstay yearsofschooling secondaryschool specificfield service nonmanual {
	use `i'.dta, replace
	merge 1:1 bmunicipality byear using mws.dta
	gen postXMWXpre1938=(postXMW==1 & byear<1938)
	gen postXMWXpost1938=(postXMW==1 & byear>=1938)
	xtset bmunicipality
	xtreg mainoutcome postXMWXpre1938 postXMWXpost1938 i.byear i.byear#i.regionXurban i.sex if wrongregister==0, fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMWXpre1938 postXMWXpost1938 i.byear i.byear#i.regionXurban i.sex if wrongregister==0 & (treated==1 | nevertreated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMWXpre1938 postXMWXpost1938 i.byear i.byear#i. i.sex if wrongregister==0 & (treated==1 | alwaystreated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMWXpre1938 postXMWXpost1938 i.byear i.byear#i.regionXurban i.sex if wrongregister==0 & (treated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
}

*Appendix K Table
use othercontrols.dta
merge 1:1 bmunicipality byear using mws.dta
*firstyearofMW = the first year since the bmunicipality has access to MW within 5.5 km radius
replace firstyearofMW=1950 if nevertreated==1
duplicates drop bmunicipality, force
	xtreg firstyearofMW urban north south lntraffic lnrailways lnmunincome shareagriculture shareindustry countygdp females under15 lncdr sharedisabled lnschools lnbirths lnpharmacies lnstillbirths lnpop lnimr lnmmr lnpneumonia sulpha if wrongregister==0, fe vce(cluster bmunicipality)
	outreg2 using randomtreatment, cttop(coefficient) word label se e(all) dec(3)
	xtreg firstyearofMW urban north south lntraffic lnrailways lnmunincome shareagriculture shareindustry countygdp females under15 lncdr sharedisabled lnschools lnbirths lnpharmacies lnstillbirths lnpop lnimr lnmmr lnpneumonia sulpha if wrongregister==0 & (treated==1 | nevertreated==1), fe vce(cluster bmunicipality)
	outreg2 using randomtreatment, cttop(coefficient) word label se e(all) dec(3)
	xtreg firstyearofMW urban north south lntraffic lnrailways lnmunincome shareagriculture shareindustry countygdp females under15 lncdr sharedisabled lnschools lnbirths lnpharmacies lnstillbirths lnpop lnimr lnmmr lnpneumonia sulpha if wrongregister==0 & (treated==1 | alwaystreated==1), fe vce(cluster bmunicipality)
	outreg2 using randomtreatment, cttop(coefficient) word label se e(all) dec(3)
	xtreg firstyearofMW urban north south lntraffic lnrailways lnmunincome shareagriculture shareindustry countygdp females under15 lncdr sharedisabled lnschools lnbirths lnpharmacies lnstillbirths lnpop lnimr lnmmr lnpneumonia sulpha if wrongregister==0 & (treated==1), fe vce(cluster bmunicipality)
	outreg2 using randomtreatment, cttop(coefficient) word label se e(all) dec(3)	
}

*Appendix L Table L.1
foreach i in lbirths {
	use `i'.dta, replace
	merge 1:1 bmunicipality byear using mws.dta
	xtset bmunicipality
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban if wrongregister==0, fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban if wrongregister==0 & (treated==1 | nevertreated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban if wrongregister==0 & (treated==1 | alwaystreated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban if wrongregister==0 & (treated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
}
foreach i in children {
	use `i'.dta, replace
	merge 1:1 bmunicipality byear using mws.dta
	xtset bmunicipality
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban if wrongregister==0, fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban if wrongregister==0 & (treated==1 | nevertreated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban if wrongregister==0 & (treated==1 | alwaystreated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban if wrongregister==0 & (treated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	
	foreach val in 0 1 2 3 {
	foreach var in motherschooling fatherses fathersector {
		capture {
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban if wrongregister==0 & `var'==`val', fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban if wrongregister==0 & (treated==1 | nevertreated==1) & `var'==`val', fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban if wrongregister==0 & (treated==1 | alwaystreated==1) & `var'==`val', fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban if wrongregister==0 & (treated==1) & `var'==`val', fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
}
}
}
}
*Table L.2
foreach i in migrant {
	use `i'.dta, replace
	merge 1:1 bmunicipality byear using mws.dta
	xtset bmunicipality
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban if wrongregister==0, fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban if wrongregister==0 & (treated==1 | nevertreated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban if wrongregister==0 & (treated==1 | alwaystreated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban if wrongregister==0 & (treated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	
	foreach val in 0 1 2 3 {
	foreach var in motherschooling fatherses fathersector {
		capture {
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban if wrongregister==0 & `var'==`val', fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban if wrongregister==0 & (treated==1 | nevertreated==1) & `var'==`val', fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban if wrongregister==0 & (treated==1 | alwaystreated==1) & `var'==`val', fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban if wrongregister==0 & (treated==1) & `var'==`val', fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
}
}
}
}
*Table L.3
foreach i in lnlabourincome disabled unemployed  {
	use `i'.dta, replace
	merge m:1 id using parental.dta
	drop _merge
	merge 1:1 bmunicipality byear using mws.dta
	xtset bmunicipality
	*(i)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban i.motherschooling i.fatherses i.fathersector if wrongregister==0, fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban i.motherschooling i.fatherses i.fathersector if wrongregister==0 & (treated==1 | nevertreated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban i.motherschooling i.fatherses i.fathersector if wrongregister==0 & (treated==1 | alwaystreated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban i.motherschooling i.fatherses i.fathersector if wrongregister==0 & (treated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	
	*(ii)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban if wrongregister==0 & motherid!=., fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban if wrongregister==0 & (treated==1 | nevertreated==1) & motherid!=., fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban if wrongregister==0 & (treated==1 | alwaystreated==1) & motherid!=., fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban if wrongregister==0 & (treated==1) & motherid!=., fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	
	*(iii)
	xtset motherid
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban if wrongregister==0 & motherid!=., fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban if wrongregister==0 & (treated==1 | nevertreated==1) & motherid!=., fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban if wrongregister==0 & (treated==1 | alwaystreated==1) & motherid!=., fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban if wrongregister==0 & (treated==1) & motherid!=., fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
}

*Table L.4
foreach i in 47 55 {
use iddates.dta, clear
stset date2, id(id) time0(date1) origin(time bdate) failure(death=1) scale(365.25) exit(time .)
compress
stsplit agesplit, at(`i' 65)
gen age=round((date2-bdate)/365.25, 1)
drop if age==.
drop if age>64
gen survived=(age>=`i' & age<=64)
merge m:1 id using parental.dta
keep id bmunicipality  byear sex survived regionXurban motherschooling fatherses fathersector
duplicates drop
gsort id -survived
by id: gen row=_n
keep if row==1
probit survived i.bmunicipality i.regionXurban#i.byear i.byear i.sex
predict p_surv
predict arg_lambda, xb
gen lambda= exp(-.5*arg_lambda^2)/(sqrt(2*_pi)*normprob(arg_lambda))
label var lambda "Inverse Mills ratio"
probit survived i.bmunicipality i.regionXurban#i.byear i.byear i.sex i.motherschooling i.fatherses i.fathersector
predict p_surv1
gen ipw=1
replace ipw=1/p_surv1
replace ipw=1 if p_surv1==.
keep id lambda ipw
save selection`i'64.dta, replace
}
foreach i in lnlabourincome   {
	use `i'.dta, replace
	merge m:1 id using selection4764.dta
	drop _merge
	merge 1:1 bmunicipality byear using mws.dta
	xtset bmunicipality
	*IPW
	reg mainoutcome postXMW i.byear i.byear#i.regionXurban i.bmunicipality if wrongregister==0 [pweight=ipw], fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	reg mainoutcome postXMW i.byear i.byear#i.regionXurban i.bmunicipality if wrongregister==0 & (treated==1 | nevertreated==1) [pweight=ipw], fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	reg mainoutcome postXMW i.byear i.byear#i.regionXurban i.bmunicipality if wrongregister==0 & (treated==1 | alwaystreated==1) [pweight=ipw], fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	reg mainoutcome postXMW i.byear i.byear#i.regionXurban i.bmunicipality if wrongregister==0 & (treated==1) [pweight=ipw], fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	
	*Heckman
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban lambda if wrongregister==0, fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban lambda if wrongregister==0 & (treated==1 | nevertreated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban lambda if wrongregister==0 & (treated==1 | alwaystreated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban lambda if wrongregister==0 & (treated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	
	*Bounds
	dis 100-1.5983
	egen threshold=xtile(mainoutcome) if postXMW==0, p(98.4017)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban if wrongregister==0 & threshold!=2, fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban if wrongregister==0 & (treated==1 | nevertreated==1) & threshold!=2, fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban if wrongregister==0 & (treated==1 | alwaystreated==1) & threshold!=2, fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban if wrongregister==0 & (treated==1) & threshold!=2, fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
}
foreach i in disabled unemployed   {
	use `i'.dta, replace
	merge m:1 id using selection5564.dta
	drop _merge
	merge 1:1 bmunicipality byear using mws.dta
	xtset bmunicipality
	*IPW
	reg mainoutcome postXMW i.byear i.byear#i.regionXurban i.bmunicipality if wrongregister==0 [pweight=ipw], fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	reg mainoutcome postXMW i.byear i.byear#i.regionXurban i.bmunicipality if wrongregister==0 & (treated==1 | nevertreated==1) [pweight=ipw], fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	reg mainoutcome postXMW i.byear i.byear#i.regionXurban i.bmunicipality if wrongregister==0 & (treated==1 | alwaystreated==1) [pweight=ipw], fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	reg mainoutcome postXMW i.byear i.byear#i.regionXurban i.bmunicipality if wrongregister==0 & (treated==1) [pweight=ipw], fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	
	*Heckman 2-stage
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban lambda if wrongregister==0, fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban lambda if wrongregister==0 & (treated==1 | nevertreated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban lambda if wrongregister==0 & (treated==1 | alwaystreated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban lambda if wrongregister==0 & (treated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	
	*Bounds
	dis 100-1.5983
	egen threshold=xtile(mainoutcome) if postXMW==0, p(98.4017)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban if wrongregister==0 & threshold!=2, fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban if wrongregister==0 & (treated==1 | nevertreated==1) & threshold!=2, fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban if wrongregister==0 & (treated==1 | alwaystreated==1) & threshold!=2, fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban if wrongregister==0 & (treated==1) & threshold!=2, fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
}

*Appendix M Table M.1
foreach i in hospitalshare earlymortality latemortality neonatalmortality premature fulltermstillbirths stillbirths sickmothers {
	use `i'.dta, replace
	merge 1:1 bmunicipality byear using mws.dta
	xtset bmunicipality
    foreach var in distance lndinstance gravity {
	xtreg mainoutcome `var' i.byear i.byear#i.regionXurban if wrongregister==0, fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome `var' i.byear i.byear#i.regionXurban if wrongregister==0 & (treated==1 | nevertreated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome `var' i.byear i.byear#i.regionXurban if wrongregister==0 & (treated==1 | alwaystreated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome `var' i.byear i.byear#i.regionXurban if wrongregister==0 & (treated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
}
}
*Appendix M Table M.2
foreach i in lnlabourincome disabled unemployed {
	use `i'.dta, replace
	merge 1:1 bmunicipality byear using mws.dta
	xtset bmunicipality
    foreach var in distance lndinstance gravity {
	xtreg mainoutcome `var' i.byear i.byear#i.regionXurban i.sex if wrongregister==0, fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome `var' i.byear i.byear#i.regionXurban i.sex if wrongregister==0 & (treated==1 | nevertreated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome `var' i.byear i.byear#i.regionXurban i.sex if wrongregister==0 & (treated==1 | alwaystreated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome `var' i.byear i.byear#i.regionXurban i.sex if wrongregister==0 & (treated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
}
}
*Appendix M Table M.3
foreach i in totalhospitalstay yearsofschooling secondaryschool specificfield service nonmanual {
	use `i'.dta, replace
	merge 1:1 bmunicipality byear using mws.dta
	xtset bmunicipality
    foreach var in distance lndinstance gravity {
	xtreg mainoutcome `var' i.byear i.byear#i.regionXurban i.sex if wrongregister==0, fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome `var' i.byear i.byear#i.regionXurban i.sex if wrongregister==0 & (treated==1 | nevertreated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome `var' i.byear i.byear#i.regionXurban i.sex if wrongregister==0 & (treated==1 | alwaystreated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome `var' i.byear i.byear#i.regionXurban i.sex if wrongregister==0 & (treated==1), fe vce(cluster bmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
}
}

*Appendix N Table
*(i)
foreach i in lnlabourincome disabled unemployed {
	use `i'.dta, replace
	merge 1:1 mmunicipality byear using mws.dta
	xtset mmunicipality
    xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban i.sex if wrongregister==0, fe vce(cluster mmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban i.sex if wrongregister==0 & (treated==1 | nevertreated==1), fe vce(cluster mmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban i.sex if wrongregister==0 & (treated==1 | alwaystreated==1), fe vce(cluster mmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban i.sex if wrongregister==0 & (treated==1), fe vce(cluster mmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
}
*(ii)
foreach i in lnlabourincome disabled unemployed {
	use `i'.dta, replace
	merge 1:1 mmunicipality byear using mws.dta
	xtset mmunicipality
    xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban i.sex if originaldistance20==0, fe vce(cluster mmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban i.sex if originaldistance20==0 & (treated==1 | nevertreated==1), fe vce(cluster mmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban i.sex if originaldistance20==0 & (treated==1 | alwaystreated==1), fe vce(cluster mmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban i.sex if originaldistance20==0 & (treated==1), fe vce(cluster mmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
}
*(iii)
foreach i in lnlabourincome disabled unemployed {
	use `i'.dta, replace
	merge 1:1 mmunicipality byear using mws.dta
	xtset mmunicipality
    xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban i.sex if wrongregister_closest==0, fe vce(cluster mmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban i.sex if wrongregister_closest==0 & (treated==1 | nevertreated==1), fe vce(cluster mmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban i.sex if wrongregister_closest==0 & (treated==1 | alwaystreated==1), fe vce(cluster mmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
	xtreg mainoutcome postXMW i.byear i.byear#i.regionXurban i.sex if wrongregister_closest==0 & (treated==1), fe vce(cluster mmunicipality)
	outreg2 using `i', cttop(coefficient) word label se e(all) dec(3)
}

***END****




